/*
 * UnHide
 * Is used to hide/show sub-list of tree's node.
 * 
 * @param {type} eThis
 * @returns {Boolean}
 */

var deleteCustomerUrl;
var deleteEventUrl;
var prepareUpdateEventUrl;

var saveIconUrl;
var editIconUrl;

$(function () {
    $("#success-done").dialog({
        modal: true,
        autoOpen: false,
        resizable: false,
        buttons: {
            Ok: function () {
                $(this).dialog("close");
            }
        }
    });
});

function createConfirmDialog(targetUrl) {

    $("#dialog-delete-confirm").dialog({
        resizable: false,
        modal: true,
        autoOpen: false,
        buttons: {
            "Yes": function () {
                window.location.href = targetUrl;
            },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });
}

function DeleteCustomer(custId, custName) {

    createConfirmDialog(deleteCustomerUrl + "/" + custId);

    $("#dialog-delete-confirm b").html(custName);
    $("#dialog-delete-confirm").dialog("open");
}

function DeleteEvent(eventId, custName, eventDesc) {

    createConfirmDialog(deleteEventUrl + "/" + eventId);

    $("#dialog-delete-confirm b").html(eventDesc);
    $("#dialog-delete-confirm").dialog("open");
}

function EditEvent(customerId, eventId) {
    window.location.href = prepareUpdateEventUrl + "/" + customerId + "/" + eventId;
}

function UnHide(eThis) {
    if (eThis.innerHTML.charCodeAt(0) == 9658) {
        eThis.innerHTML = '&#9660;'
        eThis.parentNode.parentNode.parentNode.className = '';
    } else {
        eThis.innerHTML = '&#9658;'
        eThis.parentNode.parentNode.parentNode.className = 'cl';
    }
    return false;
}

function collapseAll() {
    $('.sc').each(function () {
        this.innerHTML = '&#9658;';
        this.parentNode.parentNode.parentNode.className = 'cl';
    });
}

function expandAll() {
    $('.sc').each(function () {
        this.innerHTML = '&#9660;';
        this.parentNode.parentNode.parentNode.className = '';
    });
}